
function calculateMA(data0,dayCount) {
    var result = [];
    for (var i = 0, len = data0.length; i < len; i++) {
        if (i < dayCount) {
            result.push('-');
            continue;
        }
        var sum = 0;
        for (var j = 0; j < dayCount; j++) {
            sum += data0[i - j][1];
        }
        result.push(sum / dayCount);
    }
    return result;
}
function build_diff_data(m_short, m_long, data) {
        var result = [];
        var pre_emashort = 0;
        var pre_emalong = 0;
        for (var i = 0, len = data.length; i < len; i++) {
            var ema_short = data[i][1];
            var ema_long = data[i][1];
            
            if (i != 0) {
                ema_short = (1.0 / m_short) * data[i][1] + (1 - 1.0 / m_short) * pre_emashort;
                ema_long = (1.0 / m_long) * data[i][1] + (1 - 1.0 / m_long) * pre_emalong;
            }

            pre_emashort = ema_short;
            pre_emalong = ema_long;
            var diff = ema_short - ema_long;

            result.push(diff);
        }

        return result;
    }
 function build_dea_data(m, diff) {
        var result = [];
        var pre_ema_diff = 0;
        for (var i = 0, len = diff.length; i < len; i++) {
            var ema_diff = diff[i];
            
            if (i != 0) {
                ema_diff = (1.0 / m) * diff[i] + (1 - 1.0 / m) * pre_ema_diff;
            }
            pre_ema_diff = ema_diff;

            result.push(ema_diff);
        }

        return result;
    }
function build_macd_data(data, diff, dea) {
        var result = [];
        
        for (var i = 0, len = data.length; i < len; i++) {
            var macd = 2 * (diff[i] - dea[i]);
            result.push(macd);
        }

        return result;
    }
function ddm(data0){


	var diff=build_diff_data(12, 26, data0);
		var dea = build_dea_data(9, diff);
		var macd=build_macd_data(data0,diff,dea)
	return {
		diff:diff,
		dea:dea,
		macd:macd
		
	}
}
function setMAData(param1, param2)
        {
            var _bolls=[]
			var _stdsums=[]
			var _loc_3 = NaN;
            var _loc_4 = 0;
            var _loc_5 = 0;
            var _loc_6 = param1.length;
            var _loc_7 = Number(param1[0][1]);
            var _loc_8 = [];
            var _loc_9 = 0;
            while (_loc_9 < _loc_6)
            {
                
                _loc_7 = Number(param1[_loc_9][1]);
                _loc_4 = _loc_4 + _loc_7;
                if (_loc_9 >= (param2 - 1))
                {
                    _loc_3 = _loc_4 / param2;
                    _loc_4 = _loc_4 - param1[_loc_9 - param2 + 1][1];
                }
                else
                {
                    _loc_3 = _loc_4 / (_loc_9 + 1);
                }
				
               _bolls.push(_loc_3);
                _loc_8[_loc_9] = Math.pow(_loc_7 - _loc_3, 2);
                _loc_5 = _loc_5 + _loc_8[_loc_9];
                if (_loc_9 > (param2 - 1))
                {
                    _loc_5 = _loc_5 - _loc_8[_loc_9 - param2];
                }
               _stdsums.push(_loc_5);
                _loc_9 = _loc_9 + 1;
            }
			
            return {stdsums:_stdsums,bolls:_bolls}
        }// end function
		
function boll(param1)
        {
           var EN=20
		   var _loc_3 = NaN;
            var _loc_4 = NaN;
            var _loc_5 = NaN;
           var _bolls = [];
           var _stdsums = [];
           var _uppers = [];
           var _lowers = [];
           var maObj=setMAData(param1, EN);
		  _stdsums= maObj.stdsums
		  _bolls=maObj.bolls
            var _loc_2= param1.length;
            var _loc_6 = 0;
            while (_loc_6 < _loc_2)
            {
                
                if (_loc_6 < EN)
                {
                    _loc_5 = Math.sqrt(_stdsums[_loc_6] / (_loc_6 + 1));
                }
                else
                {
                    _loc_5 = Math.sqrt(_stdsums[_loc_6] / EN);
                }
                _loc_3 = _bolls[_loc_6] + 2 * _loc_5;
                _loc_4 = _bolls[_loc_6] - 2 * _loc_5;
                _uppers.push(_loc_3);
                _lowers.push(_loc_4);
                _loc_6 = _loc_6 + 1;
            }
            return {
				boll:_bolls,
				up:_uppers,
				low:_lowers
				
			}
        }// end function
///////////////////////KDJ///////////////////////////	

var ED = 3;
			var EK = 3;
			var CK = 255;
        var EM = 9;
		var _maxp = 0.01;
		var _minp = 1000000;	
function kdjFun(param1)
        {
			
            var _loc_3 = NaN;
            var _loc_4 = NaN;
            var _loc_5 = NaN;
            if (param1 == null)
            {
                return;
            }
         
             var _ks = [];
             var _ds = [];
             var _js = [];
            var _objs = [];
            var _loc_2 = param1.length;
            var _loc_6 = param1[0];
            if (_loc_6[3] == _loc_6[2])
            {
                _loc_3 = 17;
            }
            else
            {
                _loc_3 = (_loc_6[1] - _loc_6[2]) * 100 / (_loc_6[3] - _loc_6[2]) /  EK;
            }
            _loc_4 = _loc_3 /  ED;
            _loc_5 = 3 * _loc_3 - 2 * _loc_4;
             _ks.push(_loc_3);
             _ds.push(_loc_4);
             _js.push(_loc_5);
            if (_loc_2 == 1)
            {
                return;
            }
            var _loc_7 = 1;
            while (_loc_7 < _loc_2)
            {
                
                _loc_6 = param1[_loc_7];
                 setMinMaxPrice(_loc_7, param1);
                if ( _maxp ==  _minp)
                {
                    _loc_3 = 17;
                }
                else
                {
                    _loc_3 = (_loc_6[1] -  _minp) * 100 / ( _maxp -  _minp) /  EK + ( EK - 1) *  _ks[(_loc_7 - 1)] /  EK;
                }
                _loc_4 = _loc_3 /  ED + ( ED - 1) *  _ds[(_loc_7 - 1)] /  ED;
                _loc_5 = 3 * _loc_3 - 2 * _loc_4;
                 _ks.push(_loc_3);
                 _ds.push(_loc_4);
                 _js.push(_loc_5);
                _loc_7 = _loc_7 + 1;
            }
            return{
				K:_ks,
				D:_ds,
				J:_js
			}
        }// end function
		
		function setMinMaxPrice(param1, param2)
        {
            var _loc_4 = null;
             _minp = Number.MAX_VALUE;
             _maxp = 0.01;
            var _loc_3 = 0;
            if (param1 >=  EM)
            {
                _loc_3 = param1 -  EM + 1;
            }
            while (_loc_3 <= param1)
            {
                
                _loc_4 = param2[_loc_3];
                if (_loc_4[2] <  _minp)
                {
                     _minp = _loc_4[2];
                }
                if (_loc_4[3] >  _maxp)
                {
                     _maxp = _loc_4[3];
                }
                _loc_3 = _loc_3 + 1;
            }
            
        }// end function
		
		
		////////////////////////RSI
		var CRSI1 = 255;
        var CRSI2 = 16711935;
        var ERSI1 = 6;
        var ERSI2 = 12;
        var ERSI3 = 24;
        var _min
        var CRSI3 = 65535;
		function rsiFun(param1)
        {
           
            var _rsi1s = [];
            var _rsi2s = [];
            var _rsi3s = [];
           
            var _madatas=setMaDatas(param1);
            var _loc_2 = param1.length;
            var _loc_3 = _madatas[0];
            var _loc_4 = 0;
            while (_loc_4 < _loc_2)
            {
                
                _loc_3 = _madatas[_loc_4];
                if (_loc_3.ma4 > 0)
                {
                    _rsi1s.push(_loc_3.ma1 / _loc_3.ma4 * 100);
                }
                else
                {
                    _rsi1s.push(_rsi1s[(_loc_4 - 1)]);
                }
                if (_loc_3.ma5 > 0)
                {
                    _rsi2s.push(_loc_3.ma2 / _loc_3.ma5 * 100);
                }
                else
                {
                    _rsi2s.push(_rsi2s[(_loc_4 - 1)]);
                }
                if (_loc_3.ma6 > 0)
                {
                    _rsi3s.push(_loc_3.ma3 / _loc_3.ma6 * 100);
                }
                else
                {
                    _rsi3s.push(_rsi3s[(_loc_4 - 1)]);
                }
                _loc_4 = _loc_4 + 1;
            }
			
            return{
				R:_rsi1s,
				S:_rsi2s,
				I:_rsi3s
			}
        }// end function
		
		function setMaDatas(param1)
        {
            var _loc_3 = NaN;
            var _loc_4 = NaN;
            var _loc_5 = NaN;
            var _loc_6 = NaN;
            var _loc_7 = NaN;
            var _loc_8 = NaN;
            var _loc_9 = NaN;
            var _loc_10 = NaN;
            var _loc_11 = NaN;
            var _loc_12 = null;
            var _loc_13 = null;
            var _loc_16 = null;
            var _loc_2 = param1.length;
            var _loc_14 = param1[0];
			var _madatas=[]
            if (isNaN(_loc_14.prevclose) || _loc_14.prevlose < 0)
            {
                var _loc_17 = _loc_14[1] * 0.1;
                _loc_11 = _loc_14[1] * 0.1;
                _loc_10 = _loc_17;
                _loc_8 = _loc_17;
                _loc_7 = _loc_17;
                _loc_6 = _loc_17;
                _loc_5 = _loc_17;
                _loc_4 = _loc_17;
                _loc_3 = _loc_17;
            }
            else
            {
                _loc_9 = _loc_14[1] - _loc_14.prevclose;
                _loc_17 = Math.max(_loc_9, 0);
                _loc_10 = Math.max(_loc_9, 0);
                _loc_5 = _loc_17;
                _loc_4 = _loc_17;
                _loc_3 = _loc_17;
                _loc_17 = Math.abs(_loc_9);
                _loc_11 = Math.abs(_loc_9);
                _loc_8 = _loc_17;
                _loc_7 = _loc_17;
                _loc_6 = _loc_17;
            }
            _loc_12 = [_loc_10];
            _loc_13 = [_loc_11];
            _madatas.push({ma1:_loc_10, ma2:_loc_10, ma3:_loc_10, ma4:_loc_11, ma5:_loc_11, ma6:_loc_11});
            if (_loc_2 == 1)
            {
                return;
            }
            var _loc_15 = 1;
            while (_loc_15 < _loc_2)
            {
                
                _loc_9 = param1[_loc_15][1] - param1[(_loc_15 - 1)][1];
                _loc_10 = Math.max(_loc_9, 0);
                _loc_11 = Math.abs(_loc_9);
                _loc_12.push(_loc_10);
                _loc_13.push(_loc_11);
                _loc_16 = {};
                _loc_3 = _loc_3 + _loc_10;
                if (_loc_15 >= ERSI1)
                {
                    _loc_3 = _loc_10 + _madatas[(_loc_15 - 1)].ma1 * (ERSI1 - 1);
                    _loc_16.ma1 = _loc_3 / ERSI1;
                }
                else
                {
                    _loc_16.ma1 = _loc_3 / (_loc_15 + 1);
                }
                _loc_4 = _loc_4 + _loc_10;
                if (_loc_15 >= ERSI2)
                {
                    _loc_4 = _loc_10 + _madatas[(_loc_15 - 1)].ma2 * (ERSI2 - 1);
                    _loc_16.ma2 = _loc_4 / ERSI2;
                }
                else
                {
                    _loc_16.ma2 = _loc_4 / (_loc_15 + 1);
                }
                _loc_5 = _loc_5 + _loc_10;
                if (_loc_15 >= ERSI3)
                {
                    _loc_5 = _loc_10 + _madatas[(_loc_15 - 1)].ma3 * (ERSI3 - 1);
                    _loc_16.ma3 = _loc_5 / ERSI3;
                }
                else
                {
                    _loc_16.ma3 = _loc_5 / (_loc_15 + 1);
                }
                _loc_6 = _loc_6 + _loc_11;
                if (_loc_15 >= ERSI1)
                {
                    _loc_6 = _loc_11 + _madatas[(_loc_15 - 1)].ma4 * (ERSI1 - 1);
                    _loc_16.ma4 = _loc_6 / ERSI1;
                }
                else
                {
                    _loc_16.ma4 = _loc_6 / (_loc_15 + 1);
                }
                _loc_7 = _loc_7 + _loc_11;
                if (_loc_15 >= ERSI2)
                {
                    _loc_7 = _loc_11 + _madatas[(_loc_15 - 1)].ma5 * (ERSI2 - 1);
                    _loc_16.ma5 = _loc_7 / ERSI2;
                }
                else
                {
                    _loc_16.ma5 = _loc_7 / (_loc_15 + 1);
                }
                _loc_8 = _loc_8 + _loc_11;
                if (_loc_15 >= ERSI3)
                {
                    _loc_8 = _loc_11 + _madatas[(_loc_15 - 1)].ma6 * (ERSI3 - 1);
                    _loc_16.ma6 = _loc_8 / ERSI3;
                }
                else
                {
                    _loc_16.ma6 = _loc_8 / (_loc_15 + 1);
                }
                _madatas.push(_loc_16);
                _loc_15 = _loc_15 + 1;
            }
            return _madatas
        }// end function
		//////////////////PSY//////////////////////
		var CPSY = 255;
        var EPSY = 12;
		var EPSYMA = 6;
        var CPSYMA = 16711935;
		function psyFun(param1)
        {
          
           var  _psys = [];
            var _psymas = [];
            var _objs = [];
            var _loc_2 = param1.length;
            var _loc_3 = 0;
            var _loc_4 = 0;
            var _loc_5 = 0;
            var _loc_6 = 0;
            var _loc_7 = param1[0];
            if (isNaN(_loc_7.prevclose) || _loc_7.prevclose < _loc_7[1])
            {
                _loc_5 = 1;
            }
            else
            {
                _loc_5 = 0;
            }
            _loc_6 = _loc_5;
            _loc_3 = _loc_5 / EPSY * 100;
            _psys.push(_loc_3);
            _psymas.push(_loc_3);
            _loc_4 = _loc_3;
            var _loc_8 = [_loc_5];
            if (_loc_2 == 1)
            {
                return;
            }
            var _loc_9 = 1;
            while (_loc_9 < _loc_2)
            {
                
                if (param1[_loc_9][1] > param1[(_loc_9 - 1)][1])
                {
                    _loc_5 = 1;
                }
                else
                {
                    _loc_5 = 0;
                }
                _loc_8.push(_loc_5);
                _loc_6 = _loc_6 + _loc_5;
                if (_loc_9 >= EPSY)
                {
                    _loc_6 = _loc_6 - _loc_8[_loc_9 - EPSY];
                }
                _loc_3 = _loc_6 / EPSY * 100;
                _psys.push(_loc_3);
                _loc_4 = _loc_4 + _loc_3;
                if (_loc_9 >= EPSYMA)
                {
                    _loc_4 = _loc_4 - _psys[_loc_9 - EPSYMA];
                    _psymas.push(_loc_4 / EPSYMA);
                }
                else
                {
                    _psymas.push(_loc_4 / (_loc_9 + 1));
                }
                _loc_9 = _loc_9 + 1;
            }
			
            return{
				PSY:_psys,
				PSYMA6:_psymas
			}
        }// end function
		////////////////////////////////////////////////
		var chartType='k'
var volColorList=[]
var kChartOption={}		
function createKChartFun(objData){
	volColorList=objData.coArr
	var ddmData=ddm(objData.numList)
	var bollData=boll(objData.numList)
	var KDJ=kdjFun(objData.numList)
	var RSI=rsiFun(objData.numList)
	var PSY=psyFun(objData.numList);
	var tf=chartType=='k'?true:false
	var lastData=objData.numList[objData.numList.length-1][1];
			myChart.clear();
			kChartOption = {
			animation:false,
		
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'cross',
        }, 
		formatter: function (param) {
			var obj={}
			var arr=[]
			
                       for (var i = 0, len = param.length; i < len; i++) {
						   obj[param[i].seriesName]=param[i].value
	                
	                  }
					    arr.push('日期：' + param[0].name + '<hr size=1 style="margin: 3px 0">')
					       if(obj['candlestick']!=null){
							
						      arr.push('开盘：'+Math.round(obj['candlestick'][0]*10000)/10000+"<br>")
						      arr.push("最高："+Math.round(obj['candlestick'][3]*10000)/10000+"<br>")
						      arr.push("最低："+Math.round(obj['candlestick'][2]*10000)/10000+"<br>")
						      arr.push("收盘："+Math.round(obj['candlestick'][1]*10000)/10000+'<br><br><hr size=1 style="margin: 3px 0">')
						   }
						   if(obj['shishi']!=null){
							   arr.push('收盘：'+Math.round(obj['shishi']*10000)/10000+"<br>")
						   }
						  if(obj['MA5']!=null)
						  {
							  arr.push("MA05："+Math.round(obj['MA5']*10000)/10000+"<br>")
						      arr.push("MA10："+Math.round(obj['MA10']*10000)/10000+"<br>")
						      arr.push("MA30："+Math.round(obj['MA30']*10000)/10000+"<br>")
							 
							  
						  }
						  if(obj['MA60']!=null)
						  {
							   arr.push("MA60："+Math.round(obj['MA60']*10000)/10000+'<br><br><hr size=1 style="margin: 3px 0">')
						  }
						  if(obj['boll']!=null)
						  {
						      arr.push("boll："+Math.round(obj['boll']*10000)/10000+"<br>")
						      arr.push("up："+Math.round(obj['up']*10000)/10000+"<br>")
							  arr.push("low："+Math.round(obj['low']*10000)/10000+'<br><br><hr size=1 style="margin: 3px 0">')
						  }
						  
						  arr.push("成交量："+Math.round(obj['Volumn']*10000)/10000+'<br><br><hr size=1 style="margin: 3px 0">')
						 if(obj['MACD']!=null)
						  { 
						     arr.push("MACD："+Math.round(obj['MACD']*10000)/10000+'<br>')
						     arr.push("DIF："+Math.round(obj['DIF']*10000)/10000+'<br>')
						     arr.push("DEA："+Math.round(obj['DEA']*10000)/10000+'<br>')
						  }else if(obj['K']!=null)
						  { 
						     arr.push("K："+Math.round(obj['K']*10000)/10000+'<br>')
						     arr.push("D："+Math.round(obj['D']*10000)/10000+'<br>')
						     arr.push("J："+Math.round(obj['J']*10000)/10000+'<br>')
						  }else if(obj['R']!=null)
						  { 
						     arr.push("R："+Math.round(obj['R']*10000)/10000+'<br>')
						     arr.push("S："+Math.round(obj['S']*10000)/10000+'<br>')
						     arr.push("I："+Math.round(obj['I']*10000)/10000+'<br>')
						  }if(obj['PSY']!=null)
						  { 
						     arr.push("PSY："+Math.round(obj['PSY']*10000)/10000+'<br>')
						     arr.push("PSYMA6："+Math.round(obj['PSYMA6']*10000)/10000+'<br>')
						  }
						  
		              return arr.join('')
                        /*return [
                            '日期: ' + param[1].seriesName + '<br>',
                            '开: ' + param[0].value[0] + '<br>',
                           '高: ' + param[0].value[3] + '<br>',
						     '低: ' + param[0].value[2] + '<br>',
						    '收: ' + param[0].value[1] + '<br>',
							 '量: ' + param[5].value + '<br>',
							 '<font color="'+param[1].color+'">'+'MA5: ' + param[1].value + '</font><br>',
							  '<font color="'+param[2].color+'">'+'MA10: ' + param[2].value + '</font><br>',
							   '<font color="'+param[3].color+'">'+'MA30: ' + param[3].value + '</font><br>',
							   '<font color="'+param[4].color+'">'+ 'MA60: ' + param[4].value + '</font><br>'
		
                          
                            
                        ];*/
                    }
    },
    legend: [{show:false,
        data: ['candlestick','shishi','MA5', 'MA10', 'MA30', 'MA60', 'boll', 'up', 'low'],
		//selected:{'MA5': true,'MA10': true,'MA30': true,'MA60': true,'boll': false,'up': false,'low': false}
		
		selected:{'candlestick':tf,'MA5': tf,'MA10': tf,'MA30': tf,'MA60': true,'shishi':!tf,'boll': false,'up': false,'low': false}
    },{show:false,
	top:'30px',
        data: ['MACD','DIF','DEA','K','D','J','R','S','I','W','R','PSY','PSYMA6'],
		selected:{'MACD': true,'DIF': true,'DEA': true,'K': false,'D': false,'J': false,'R': false,'S': false,'I': false,'W': false,'R': false,'PSY': false,'PSYMA6': false}
		
    }],
    grid: [           {
      left: '30',
      right: 80,
       bottom: '240',
  },{
      left: '30',
      right: 80,
       bottom: '140',
      height: '100'
  },{
      left: '30',
      right: 80,
      bottom: '40',
      height: '100'
  }],
  axisPointer: {
           link: {xAxisIndex: 'all'},
            label: {
                backgroundColor: '#f00'
            },
        },
    xAxis: [
	{
        type: 'category',
        data: objData.dateList,
        scale: true,
        boundaryGap : true,
		axisPointer: {label:{show:false}},
		axisLabel: {
			show:false,
            
        },
		  axisTick: {show: false},
        axisLine: {onZero: false},
        splitLine: {show: false},
        splitNumber: 20,
        min: 'dataMin',
    }
	,{
      type: 'category',
      gridIndex: 1,
      data: objData.dateList,
	   axisTick: {show: false},
	  axisPointer: {label:{show:false}},
      axisLabel: {show: false},
	   boundaryGap : true,
  },{
      type: 'category',
      gridIndex: 2,
      data: objData.dateList,
      axisLabel: {
			textStyle: {
              color: '#ccc'
            },
			formatter: function (value) {
				if(tpid==5){
				    var geshi='MM月dd日'
				}else if(tpid>5){
					var geshi='yyyy年MM月'
				}else{
					geshi='hh:mm'
				}
                return echarts.format.formatTime(geshi, value);
            }
	  },
	   boundaryGap : true,
  }
	],
    yAxis: [
	{
      scale: true,
	  
	  axisLabel:{
		  textStyle:{
			  color:'#ccc',
		  }
	  },
	  
      splitArea: {
          show: false
      },
	    splitLine: {
			lineStyle: {
              color: 'rgb(40, 40, 40)',
            }
			},
	  position:'right',
  },{
      gridIndex: 1,
      splitNumber: 1,
	  scale:true,
	  position:'right',
      axisLine: {onZero: false},
      axisTick: {show: true},
      splitLine: {show: false},
      axisLabel: {show: false,
	  textStyle:{
			  color:'#ccc',
		  }}
  },{
	  gridIndex: 2,
     // splitNumber: 1,
	  position:'right',
	  scale: true,
      axisLine: {onZero: false},
      axisTick: {show: true},
      splitLine: {show: false},
      axisLabel: {show: true,
	  textStyle:{
			  color:'#ccc',
		  }}
  }],
   dataZoom: [{
    	  type: 'inside',
          xAxisIndex: [0, 0],
          start: 0,
          end: 100
  	},{
       
          xAxisIndex: [0, 1],
          type: 'inside',
          top: '97%',
          start: 0,
          end: 100
  	},{
      
      xAxisIndex: [0, 2],
      type: 'inside',
      start: 0,
      end: 100
  }],
    series: [
        {
            name: 'candlestick',
            type: 'candlestick',
            data: objData.numList,
			
			 barMaxWidth:20,
			 itemStyle: {
                normal: {
                    color: '#FD1050',
                    color0: '#0CF49B',
                    borderColor: '#FD1050',
                    borderColor0: '#0CF49B',
                },
            },
			 
            
        },
        {
            name: 'MA5',
            type: 'line',
            data: calculateMA(objData.numList,5),
            smooth: true,
			symbol:'none',
            lineStyle: {
                normal: {width:1}
            }
        },
        {
            name: 'MA10',
            type: 'line',
            data: calculateMA(objData.numList,10),
            smooth: true,
			symbol:'none',
            lineStyle: {
                normal: {width:1}
            }
        },
        {
            name: 'MA30',
            type: 'line',
            data: calculateMA(objData.numList,30),
            smooth: true,
			symbol:'none',
            lineStyle: {
                normal: {width:1}
            }
        },
        {
            name: 'MA60',
            type: 'line',
            data: calculateMA(objData.numList,60),
			data:bollData.boll,
            smooth: true,
			symbol:'none',
			
            lineStyle: {
                normal: {width:1}
            }
        },{
            name: 'boll',
            type: 'line',
		   data:bollData.boll,
            smooth: true,
			symbol:'none',
            lineStyle: {
                normal: {width:1}
            }
        },
        {
            name: 'up',
            type: 'line',
           data:bollData.up,
            smooth: true,
			symbol:'none',
            lineStyle: {
                normal: {width:1}
            }
        },
        {
            name: 'low',
            type: 'line',
            data:bollData.low,
            smooth: true,
			symbol:'none',
			
            lineStyle: {
                normal: {width:1}
            }
        },{
            name: 'shishi',
            type: 'line',
            data:objData.shishi,
            smooth: true,
			symbol:'none',
			
            lineStyle: {
                normal: {width:1}
            },
			markPoint: {
            symbol: 'rect',
            animation: true,
			itemStyle: {
            normal: {
                color: '#ff9900',
             
            }
        },
            symbolSize: [
              60,
              18
            ],
            symbolOffset: [
              -45,
              0
            ],
			
            data: [
              {
                name: '最新价',
                x: '100%',
				yAxis:lastData,
               
                label: {
                  normal: {
                    show: true,
                    position: [
                      5,
                      1
                    ],
                    textStyle: {
                      color: '#FFFFFF',
                    },
                  }
                },
              }
            ]
          },
           markLine: {
			   animation: false,
                symbolSize: 0,
				label: {
              normal: {
                show: true,
              }
            },
			 lineStyle: {
              normal: {
				  color:'#ff0000',
                type: 'dashed',
                width: 1,
              },
            },
		
                data: [
                    [
                        {
                          
                            
                            label: {
                                normal: {show: false},
                                emphasis: {show: false}
                            },
							x:'0%',
							yAxis:lastData,
							
                        },
                        {
                           
                            label: {
                                normal: {show: false},
                                emphasis: {show: false}
                            },
							x:'99%',
							yAxis:lastData,
							
                        }
                    ]
                ]
            },
        },{
          name: 'Volumn',
          type: 'bar',
          xAxisIndex: 1,
          yAxisIndex: 1,
		  barMaxWidth:20,
          data: objData.vol,
        itemStyle: {
	    	  normal: {
		          color: function(params) {
		              var colorList;
					 
					  colorList=volColorList[params.dataIndex]
		              return colorList;
		          },
		      }
	      }
      },{
          name: 'MACD',
          type: 'bar',
          xAxisIndex: 2,
          yAxisIndex: 2,
		  barMaxWidth:20,
          data: ddmData.macd,
          itemStyle: {
	    	  normal: {
		          color: function(params) {
		              var colorList;
		              if (params.data >= 0) {
		                  colorList = '#ef232a';
		              } else {
		                  colorList = '#14b143';
		              }
		              return colorList;
		          },
		      }
	      },
		  lineStyle: {
                normal: {width:1}
            }
      },{
          name: 'DIF',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: ddmData.diff,
		  lineStyle: {
                normal: {width:1}
            }
      },{
          name: 'DEA',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: ddmData.dea,
		  lineStyle: {
                normal: {width:1}
            }
      }
	  ,{
          name: 'K',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: KDJ.K,
		  lineStyle: {
                normal: {width:1}
            }
      }
	  ,{
          name: 'D',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: KDJ.D,
		  lineStyle: {
                normal: {width:1}
            }
      }
	  ,{
          name: 'J',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: KDJ.J,
		  lineStyle: {
                normal: {width:1}
            }
      }
	  ,{
          name: 'R',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: RSI.R,
		  lineStyle: {
                normal: {width:1}
            }
      }
	  ,{
          name: 'S',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: RSI.S,
		  lineStyle: {
                normal: {width:1}
            }
      }
	  ,{
          name: 'I',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: RSI.I,
		  lineStyle: {
                normal: {width:1}
            }
      }
	  ,{
          name: 'PSY',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
         data: PSY.PSY,
		 lineStyle: {
                normal: {width:1}
            }
      }
	  ,{
          name: 'PSYMA6',
          type: 'line',
		  symbol:'none',
          xAxisIndex: 2,
          yAxisIndex: 2,
          data: PSY.PSYMA6,
		  lineStyle: {
                normal: {width:1}
            }
      }
		
       

    ]
};
             myChart.setOption(kChartOption);
			 changeMiFun(MI)
			  changeViFun(VI)
			 window.onresize = myChart.resize
        }
		
function updataKChartFun(data){
	var dateList=data.dateList
	var numList=data.numList
	var ddmData=ddm(numList)
	var bollData=boll(numList)
	var KDJ=kdjFun(numList)
	var RSI=rsiFun(numList)
	var PSY=psyFun(numList)
	volColorList=data.coArr
	kChartOption.xAxis[0].data=dateList
	kChartOption.xAxis[1].data=dateList
	kChartOption.xAxis[2].data=dateList
	
	if(chartType=='k'){
		kChartOption.series[0].data=numList
	kChartOption.series[1].data=calculateMA(numList,5)
	kChartOption.series[2].data=calculateMA(numList,10)
	kChartOption.series[3].data=calculateMA(numList,30)
	}else{
	
	kChartOption.series[8].data=data.shishi
	
	}
	kChartOption.series[4].data=calculateMA(numList,60)
	kChartOption.series[5].data=bollData.boll
	kChartOption.series[6].data=bollData.up
	kChartOption.series[7].data=bollData.low
	kChartOption.series[9].data=data.vol
	kChartOption.series[10].data=ddmData.macd
	kChartOption.series[11].data=ddmData.diff
	kChartOption.series[12].data=ddmData.dea
	kChartOption.series[13].data=KDJ.K
	kChartOption.series[14].data=KDJ.D
	kChartOption.series[15].data=KDJ.J
	kChartOption.series[16].data=RSI.R
	kChartOption.series[17].data=RSI.S
	kChartOption.series[18].data=RSI.I
	kChartOption.series[19].data=PSY.PSY
	kChartOption.series[20].data=PSY.PSYMA6
	
	
	myChart.setOption(kChartOption);
}
function updataShiShiChartFun(data)
{
	var value=data.ticker.last
	var shishiData=kChartOption.series[8].data
	kChartOption.series[8].data[shishiData.length-1]=value
	var mark_point=kChartOption.series[8].markPoint;
			/*mark_point.data[0].value = value;*/
            mark_point.data[0].yAxis = value;
	var mark_line=kChartOption.series[8].markLine;
	mark_line.data[0][0].yAxis = value;
	mark_line.data[0][1].yAxis = value;
	myChart.setOption(kChartOption);
}
        //////////////////////////////////////////////////////
function changeMiFun(idName)
  {MI=idName
	  if(idName=="BOLL"){
		  kChartOption.legend[0].selected= {'MA5': false,'MA10': false,'MA30': false,'MA60': false,'boll': true,'up': true,'low': true}
	  }else {
		  var tf=chartType=='k'?true:false;
		  kChartOption.legend[0].selected= {'MA5': tf,'MA10': tf,'MA30': tf,'MA60': true,'boll': false,'up': false,'low': false}
	  }

   myChart.setOption(kChartOption);
 }
 function changeViFun(idName)
  { VI=idName
    var obj={'MACD': false,'DIF': false,'DEA': false,'K': false,'D': false,'J': false,'R': false,'S': false,'I': false,'PSY': false,'PSYMA6': false};
	  if(idName=="MACD"){
		 obj.MACD=true
		 obj.DIF=true;
		 obj.DEA=true;
	  }else if(idName=="KDJ"){
		 obj.K=true
		 obj.D=true;
		 obj.J=true;
	  }
	  else if(idName=="RSI"){
		 obj.R=true
		 obj.S=true;
		 obj.I=true;
	  }
	  else if(idName=="PSY"){
		 obj.PSY=true
		 obj.PSYMA6=true;
	  }
	  kChartOption.legend[1].selected=obj

   myChart.setOption(kChartOption);
 }